package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {
  private double balance;
  private double overdraft;
  
  public CheckingAccount(double balance, double overdraft) {
    this.balance = balance;
    this.overdraft = overdraft;
  }
  @Override
  public void deposit(double x) {
    balance +=x;
  }

  @Override
  public void withdraw(double x) {
    if(x > this.balance){
      overdraft -= (x-balance);
      balance = 0;
    }
  }
  
  @Override
  public double maximumAmountToWithdraw(){
    return balance + overdraft;
  }
  
  @Override
  public double getBalance(){
    return this.balance;
  }
}
